﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WMM.Tapioca.Linkbase;
using WMM.Tapioca.Instance;
using WMM.Tapioca.Taxonomy;

namespace WMM.Tapioca.Formula.Filters
{
    /// <summary>
    /// The forever filter can be used to match facts that are reported with a forever period. 
    /// </summary>
    public class ForeverFilter : Filter
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        public ForeverFilter(Resource resource)
            : base(resource)
        {
           
        }


        public override List<FactItem> EvaluateFilter(VariableSet variableSet, List<FactItem> itemsToFilter, DTS dts)
        {
            List<FactItem> itemListTemp = new List<FactItem>();

            foreach (FactItem item in itemsToFilter)
            {
                if (Complement ? !item.ContextRef.IsForeverPeriod : item.ContextRef.IsForeverPeriod)
                {
                    itemListTemp.Add(item);
                }
            }

            return itemListTemp;
        }
    }
}
